import RequestProcess from "./RequestProcess";
import OperateArgs from "../operator/OperateArgs";
import OperatorDecorator from "../operator/OperatorDecorator";
import BuildFriendOperation from "../operator/BuildFriendOperation";
import { RC } from "../config/RC";
import CheckUserIdExistOperator from "../operator/CheckUserIdExistOperator";
import GetFriendAndGroupOperator from "../operator/GetFriendAndGroup";


class GetFriendAndGroupRequestOperation extends RequestProcess {

    public args_generate(): void {
        this.args = new OperateArgs();
        this.args.setProperty("userId", this.req.body.userId);
    }

    public operator_plan_generate(): void {
        const check_userId_Exist = new CheckUserIdExistOperator(this.args);
        const get_friend_and_group_operator = new GetFriendAndGroupOperator(this.args);

        this.operator_plan = new OperatorDecorator(check_userId_Exist,get_friend_and_group_operator);
    }

    public writeResult(rc: RC): Object {
        switch (rc) {
            case RC.SUCCESS:
                return {
                    code: "0000",
                    msg: "成功获取信息",
                    messages:this.args.getProperty("information")
                }
            case RC.INTERNAL_ERROR:
                return {
                    code: "1003",
                    msg: "服务器内部错误"
                }
            default:
                return {
                    code: "2000",
                    msg: "未知错误"
                }
        }
    }
}

export default GetFriendAndGroupRequestOperation;